package com.kvest.view_pager_test.adapter;

import android.R;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.FragmentStatePagerAdapter;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import com.kvest.view_pager_test.fragment.CustomListFragment;
import com.kvest.view_pager_test.fragment.CustomMapFragment;
import com.kvest.view_pager_test.fragment.SelfListFragment;

/**
 * Created with IntelliJ IDEA.
 * User: Kvest
 * Date: 17.03.13
 * Time: 22:16
 * To change this template use File | Settings | File Templates.
 */
public class MyFragmentPagerAdapter extends FragmentStatePagerAdapter {
    //4)  FragmentPagerAdapter, FragmentStatePagerAdapter - difference
    private static final int COUNT = 6;

    public MyFragmentPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int i) {
        switch (i) {
            case 0 : return getMapFragment();
            case 1 : return new CustomListFragment(android.R.layout.simple_list_item_1);
            case 2 : return SelfListFragment.newInstamce(7, "for test");
            case 3 : return new CustomListFragment(R.layout.simple_list_item_checked);
            case 4 : return new CustomListFragment(R.layout.simple_list_item_single_choice);
            case 5 : return new CustomListFragment(R.layout.simple_list_item_multiple_choice);

            default: return null;
        }
    }

    private Fragment getMapFragment() {
        return new CustomMapFragment();
//        SupportMapFragment result = SupportMapFragment.newInstance();
//        LatLng position = new LatLng(50.5, 30.5);
//        MarkerOptions mo = new MarkerOptions().position(position).snippet("").title("Kiev");
//        if (result.getMap() != null) {
//            result.getMap().addMarker(mo);
//        }
//        return result;
    }

    @Override
    public int getCount() {
        return COUNT;  //To change body of implemented methods use File | Settings | File Templates.
    }
}
